<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="author" content="featon inc.">
    <link rel="stylesheet" href="/static/vendor/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/vendor/bootstrap/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/static/vendor/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/vendor/jqPagination/css/jqpagination.css">
    <link rel="stylesheet" href="/static/vendor/datetimepicker/jquery.datetimepicker.css">
    <link rel="stylesheet" href="/static/vendor/skin/ftskin.css">
    <title>HelloWorld</title>
</head>
<body>
<div class="ft-subpage-wrapper container-fluid">
    <div class="row">
        <div class="col-lg-12">
            <div class="tools-box">
                <div class="form-inline">
                    <div class="form-group">
                        <button type="button" class="btn btn-info" onclick="openAddPage()"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 添加</button>
                        <button type="button" class="btn btn-warning" onclick="updateRecord(table,'role_id','openUpdatePage()');"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> 修改</button>
                        <button type="button" class="btn btn-danger" onclick="deleteRecord(table,'role_id','deleteObject()');"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> 删除</button>
                    </div>
                    <span style="float:right;display:none;">
                        <table style="text-align:left;padding-right:5px;float:right" cellspacing="0" cellpadding="0" border="0">
                            <tr>
                                <td width="195">
                                    <div class="input-group">
                                        <input type="text" class="form-control" placeholder="关键字">
                                        <span class="input-group-btn">
                                            <button class="btn btn-info" type="button"><span class="glyphicon glyphicon-search" aria-hidden="true"></span> 查询</button>
                                        </span>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </span>
                </div>

            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12" id="table">
        </div>
    </div>
    <div class="row">
        <div id="turn">
        </div>
    </div>
</div>
<script src="/static/vendor/jquery/jquery-3.3.1.min.js"></script>
<script src="/static/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/vendor/jqPagination/js/jquery.jqpagination.min.js"></script>
<script src="/static/vendor/skin/js/ft-ui.js"></script>
<script src="/static/vendor/skin/js/table-common.js"></script>
<script src="/static/vendor/skin/js/java.js"></script>
<script src="/static/vendor/skin/js/jquery.c.js"></script>
<script>
    var tp = new TurnPage();
    var table = new Table();
    table.table_name = "table_list";
    var beanList = null;
    var con_map = new Map();

    jQuery(function($){
        initTable();
        loadListble()
    });

    function initTable(){

        var colsMap = new Map();
        var colsList = new List();

        colsList.add(setTitleClos("qy_name","企业名称","180px","","",""));//英文名，显示名，宽，高，样式名，点击事件　
        colsList.add(setTitleClos("legal_man","负责人","80px","","",""));
        colsList.add(setTitleClos("phone","电话","80px","","",""));
        colsList.add(setTitleClos("start_dq","启运地","250px","","",""));
        colsList.add(setTitleClos("end_dq","目的地","250px","","",""));
        colsList.add(setTitleClos("bee_type_1","中蜂类型","100px","","",""));
        colsList.add(setTitleClos("record_man","登记人","80px","","",""));
        colsList.add(setTitleClos("record_time","登记时间","120px","","",""));
        colsList.add(setTitleClos("action_col","操作","200px","","",""));
        colsList.add(setTitleClos("space_col"," ","","","",""));

        table.setColsList(colsList);
        table.setAllColsList(colsList);
        table.enableSort=false;//禁用表头排序
        table.onSortChange = showList;
        table.show("table");//里面参数为外层div的id
    }

    function loadListble()
    {
        showList();
        showTurnPage();
    }

    function showList(){
        con_map.put("start_num", tp.getStart());
        con_map.put("page_size", tp.pageSize);

        beanList = top.ajax.synclBody("/tran/getTranListin",con_map.toJSON())

        curr_bean = null;
        table.setBeanList(beanList,"td_list");//设置列表内容的样式
        table.show("table");

        table.getCol("start_dq").each(function(i){
            if(i>0)
            {
                $(this).html(beanList[i-1].start_dq_1_id+" "+beanList[i-1].start_dq_2_id+" "+beanList[i-1].start_dq_3_id+" "+beanList[i-1].start_dq_4_id);
            }
        });
        table.getCol("end_dq").each(function(i){
            if(i>0)
            {
                $(this).html(beanList[i-1].end_dq_1_id+" "+beanList[i-1].end_dq_2_id+" "+beanList[i-1].end_dq_3_id+" "+beanList[i-1].end_dq_4_id);
            }
        });
        table.getCol("action_col").each(function(i){
            if(i>0)
            {
                $(this).html('<a href="javascript:openUpdatePage(\''+beanList[i-1].id+'\')">编辑</a>&nbsp;&nbsp;<a href="javascript:deleteSingleObject(\''+beanList[i-1].id+'\')">删除</a>');
            }
        });
    }

    function showTurnPage(){
        tp.total = top.ajax.synclBody("/tran/getTraninCount",con_map.toJSON())
        tp.show("turn","");
        tp.onPageChange = showList;
    }

    function openAddPage() {
        top.addTab("/tran/goin_add");
    }

    function openUpdatePage(id) {
        var sel_id = '';
        if (id != '' && id != null) {
            sel_id = id;
        } else {
            sel_id = table.getSelecteCheckboxValue("id");
        }
        top.addTab("/tran/goin_add?tran_id=" + sel_id);
    }

    function deleteObject(id) {
        var sel_id = '';
        if (id != '' && id != null) {
            sel_id = id;
        } else
        {
            sel_id = table.getSelecteCheckboxValue("id");
        }
        var dm = new Map();
        dm.put('id', "'" + sel_id.replace(/,/ig, "','") + "'");
        if (top.ajax.synclBody("/tran/del", dm.toJSON())) {
            modelWindow.alert(top.CMSLang.Delete_success);
            loadListble();
        } else {
            modelWindow.error(top.CMSLang.Delete_fail);
        }ww
    }


    function deleteSingleObject(id,user_id) {
        modelWindow.confirm("是否删除该条记录", "deleteObject('" + id + "')")
    }



    function changeList(value,item)
    {
        if(value == '')
        {
            con_map.remove(item);
        }else
        {
            con_map.put(item,value);
        }
        tp.curr_page=1;
        loadListble();
    }

    function fnSearch()
    {
        changeList($('#search_key').val(),'kw');
    }
</script>
</body>
</html>
